﻿using System;
using System.Collections;
using System.Collections.Generic;

using IBatisNet.DataAccess;

using AUV5.Model;
using AUV5.DAL;
using AUV5.DAL.Interface;
using AUV5.DAL.Dao;

namespace AUV5.BLL
{
    /// <summary>
    /// 功能：     PaymentHistory业务逻辑实现
    /// 作者：     Wilson
    /// 日期：     2011/11/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class PaymentHistoryBLL
    {
        private static PaymentHistoryBLL instance = new PaymentHistoryBLL();
        private IDaoManager daoManager = ServiceConfig.Instance.DaoManager;
        private IPaymentHistoryDao dao = null;

        private PaymentHistoryBLL()
        {
            dao = PaymentHistorySqlMapDao.GetInstance();
        }

        public static PaymentHistoryBLL GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                //daoManager.BeginTransaction();

                int count = dao.GetMaxCounts();

                //daoManager.CommitTransaction();

                return count;
            }
            catch
            {
                //daoManager.RollBackTransaction();
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<PaymentHistory> GetList()
        {
            try
            {
                //daoManager.BeginTransaction();

                System.Collections.Generic.IList<PaymentHistory> list = dao.GetList();

                //daoManager.CommitTransaction();

                return list;
            }
            catch
            {
                //daoManager.RollBackTransaction();
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="TopCounts"></param>
        /// <returns></returns>
        private System.Collections.Generic.IList<PaymentHistory> GetListByParameters(object TopCounts, PaymentHistory paymenthistory)
        {
            try
            {
                //daoManager.BeginTransaction();

                Hashtable ht = new Hashtable();
                ht.Add("TopCounts", TopCounts);
                System.Collections.Generic.IList<PaymentHistory> list = dao.GetListByParameters(ht);

                //daoManager.CommitTransaction();

                return list;
            }
            catch
            {
                //daoManager.RollBackTransaction();
                throw;
            }
        }


        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="HistoryId"></param>
        /// <returns></returns>
        public PaymentHistory GetDetail(System.String historyid)
        {
            try
            {
                ///daoManager.BeginTransaction();

                return dao.GetDetail(historyid);

                ///daoManager.CommitTransaction();
            }
            catch
            {
                ///daoManager.RollBackTransaction();
                throw;
            }
        }


        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="paymenthistory"></param>
        /// <returns></returns>
        public object Add(PaymentHistory paymenthistory)
        {
            //int id = GetId("SYS_UserInfoTemp");
            //sys_userinfotemp.UserID = id;

            try
            {
                ///daoManager.BeginTransaction();

                return dao.Add(paymenthistory);
                ///daoManager.CommitTransaction();
            }
            catch
            {
                ///daoManager.RollBackTransaction();
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="paymenthistory"></param>
        /// <returns></returns>
        public int Update(PaymentHistory paymenthistory)
        {
            try
            {
                ///daoManager.BeginTransaction();

                return dao.Update(paymenthistory);

                ///daoManager.CommitTransaction();
            }
            catch
            {
                ///daoManager.RollBackTransaction();
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="HistoryId"></param>
        /// <returns></returns>
        public int Delete(System.String historyid)
        {
            try
            {
                ///daoManager.BeginTransaction();

                return dao.Delete(historyid);

                ///daoManager.CommitTransaction();
            }
            catch
            {
                ///daoManager.RollBackTransaction();
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="paymenthistory"></param>
        /// <returns></returns>
        public int Delete(PaymentHistory paymenthistory)
        {
            try
            {
                ///daoManager.BeginTransaction();

                return dao.Delete(paymenthistory);

                ///daoManager.CommitTransaction();
            }
            catch
            {
                ///daoManager.RollBackTransaction();
                throw;
            }
        }
    }
}
